from itertools import count
from primes import prime

limit = 50 * 1000 * 1000
nrs = set()

for c in prime():
    cp = c ** 4
    if cp > limit: break
    
    for b in prime():
        bp = b ** 3
        if bp + cp > limit: break
        
        for a in prime():
            ap = a ** 2
            if ap + bp + cp > limit: break
            
            nrs.add(ap + bp + cp)
            
print len(nrs)
            
            
